# Maintainer: Sven-Hendrik Haase <svenstaro@gmail.com>
# Contributor: Peter Hatina <phatina AT gmail.com>
pkgname=glm
pkgver=0.9.9.8
pkgrel=1
pkgdesc="C++ mathematics library for 3D software based on the OpenGL Shading Language (GLSL) specification"
arch=('any')
license=('MIT')
url="http://glm.g-truc.net"
source=("https://github.com/g-truc/glm/releases/download/${pkgver}/glm-${pkgver}.zip"
        glm.pc.in
        glmConfigVersion.cmake.in
        glmConfig.cmake.in
        glmTargets.cmake)
sha512sums=('8c6bdaacfac600a22d7e92b86f70bfcfe7bf7f56b05ad93c503520adbdb8432ca20c01e93a5c782cf457fe4512b29defffdc94a1316bc7f3d6747f989fff0286'
            '37f3973b9913fb820a355160717cbe881586a00210c76061c436784d240eec0094132d8fb772126f8ab9cd75d3ed2da9ccb5a5c33dbdd007d77e5eca82990d25'
            'e8342b07a44fd3fab9c1262e670dda27ac22758d2bd9a682e1d82b1caba1846c2ae8b53a75a556f8cd75e961a175d6a035abd6cf545b8c05b12d2898567119fa'
            '517b080a50f9ba80b5d1e15c27e9c1905912c1db640eb087272be853ad4e451a302e6b4bee4f7e5c936cadfda3a7a75421c4df1bab3759b147fbb770061cfa9a'
            'ebaf7ad8ded0abe56074cb67f8238224458587bb16223e19493819a867f0dc536114f7ddb83285b990a8bdeca246b29dacae90998386be2225397681e7c0e77d')

package() {
    cd $pkgname

    mkdir -p "$pkgdir"/usr/include/
    cp -r glm "$pkgdir"/usr/include/

    mkdir -p "$pkgdir"/usr/share/doc
    cp -r doc "$pkgdir"/usr/share/doc/glm

    # For some stupid reason, glm upstream removed the CMake install target here:
    # https://github.com/g-truc/glm/commit/5f352ecce21bb1ab37fa56fac0f383c779b351a3
    # There is no reasoning for it. Discussion here: https://github.com/g-truc/glm/issues/947
    mkdir -p "$pkgdir"/usr/lib/pkgconfig/
    sed "s/@VERSION@/$pkgver/" "$srcdir"/glm.pc.in > "$pkgdir"/usr/lib/pkgconfig/glm.pc

    mkdir -p "$pkgdir"/usr/lib/cmake/glm/
    sed "s/@VERSION@/$pkgver/" "$srcdir"/glmConfigVersion.cmake.in > "$pkgdir"/usr/lib/cmake/glm/glmConfigVersion.cmake
    sed "s/@VERSION@/$pkgver/" "$srcdir"/glmConfig.cmake.in > "$pkgdir"/usr/lib/cmake/glm/glmConfig.cmake
    install -Dm644 "$srcdir"/glmTargets.cmake "$pkgdir"/usr/lib/cmake/glm/glmTargets.cmake
}
